﻿// 模块接口
public interface IModuleBase
{
    void Init();
    string GetName();
    void Update(float dt);
    void FixedUpdate(float dt);
    void Dispose();
}

// 模块基类
public class ModuleBase<T> : IModuleBase where T : IModuleBase
{
    static T ms_instance;
    public static T Instance
    {
        get
        {
            if (ms_instance == null)
            {
                ms_instance = Framework.Instance.GetModule<T>();
            }
            return ms_instance;
        }
    }

    protected string m_fullname;
    public ModuleBase()
    {

    }

    // 获取模块名称
    public string Name
    {
        get
        {
            if (string.IsNullOrEmpty(m_fullname))
            {
                m_fullname = GetType().FullName;
            }
            return m_fullname;
        }
    }

    public string GetName()
    {
        return Name;
    }

    public virtual void Init()
    {

    }

    public virtual void Update(float dt)
    {

    }

    public virtual void FixedUpdate(float dt)
    {

    }

    public virtual void Dispose()
    {

    }
}
